﻿using LJ.Abstractions.Config;
using LJ.EventBus.FastDog.Transport.Abstractions;
using LJ.EventBus.FastDog.Transport.Abstractions.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.EventBus.FastDog.Transport.Kafka.Internal;

public class KafkaConsumerClientFactory(IConfigProvider configProvider) : IConsumerClientFactory
{
    private readonly EventBusTransportConfig _eventBusTransportConfig = configProvider.Get<EventBusTransportConfig>();

    public virtual IConsumerClient Create(string groupName)
    {
        try
        {
            return new KafkaConsumerClient(groupName, _eventBusTransportConfig);
        }
        catch (Exception e)
        {
            throw new BrokerConnectionException(e);
        }
    }
}
